package org.lc.design.samples.case1;

public class UserInfo {

    private String name;

    private String sex;

    private String phoneNumber;

    private String age;

    private String idNumber;

    public UserInfo() {
    }

    /**
    * 私有化构造函数，只能通过Builder构建
    * @author lc
    * @date 2024/4/3
    */
    private UserInfo(String name, String sex, String phoneNumber, String age, String idNumber) {
        this.name = name;
        this.sex = sex;
        this.phoneNumber = phoneNumber;
        this.age = age;
        this.idNumber = idNumber;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }

    public String getIdNumber() {
        return idNumber;
    }

    public void setIdNumber(String idNumber) {
        this.idNumber = idNumber;
    }

    @Override
    public String toString() {
        return "UserInfo{" +
                "name='" + name + '\'' +
                ", sex='" + sex + '\'' +
                ", phoneNumber='" + phoneNumber + '\'' +
                ", age='" + age + '\'' +
                ", idNumber='" + idNumber + '\'' +
                '}';
    }

    /**
    * 静态内部类
    * @author lc
    * @date 2024/4/3
    */
    public static class Builder {

        private UserInfo userInfo = new UserInfo();

        public Builder() {
        }

        public Builder setName(String name) {
            this.userInfo.name = name;
            return this;
        }

        public Builder setSex(String sex) {
            this.userInfo.sex = sex;
            return this;
        }

        public Builder setPhoneNumber(String phoneNumber) {
            this.userInfo.phoneNumber = phoneNumber;
            return this;
        }

        public Builder setAge(String age) {
            this.userInfo.age = age;
            return this;
        }

        public Builder setIdNumber(String idNumber) {
            this.userInfo.idNumber = idNumber;
            return this;
        }

        /**
        * 构建userInfo对象
        * @author lc
        * @date 2024/4/3
        */
        public UserInfo build() {
            return userInfo;
        }
    }
}

